#include <unistd.h>
#include <fcntl.h>
#include <glib.h>

gint main(gint argc, gchar **argv)
{
    int fd = 0;
    GIOChannel *channel = NULL;
    GIOStatus st = G_IO_STATUS_ERROR;
    gchar *str_return;
    gsize length, terminator_pos;
    GError *error = NULL;

    fd = open("/etc/os-release", O_RDONLY);

    channel = g_io_channel_unix_new (fd);

    while(1) {
        st = g_io_channel_read_line (channel, &str_return, &length, &terminator_pos,&error);
        if(G_IO_STATUS_NORMAL == st) {
            g_print("read_line: %s \n", str_return);
        } else {
            g_print("read error: %d! \n", st);
            break;
        }
    }

    g_io_channel_shutdown (channel, TRUE, &error);
    close(fd);

    return 0;
}